<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://suryani.cn/support/tags" prefix="page"%>

<!DOCTYPE html>
<html lang="${lang}">
<head>
<title>手机支付管理-申请开通手机支付功能的用户列表</title>
<base href="${base }" />
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lte IE 8]>
	<script language="javascript" type="text/javascript" src="excanvas.min.js"></script>
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="less/default.less">
<script type="text/javascript" src="js/less.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.stickymenu.js"></script>
<script type="text/javascript" src="js/emm-1.0.js"></script>
<script type="text/javascript" src="js/jquery.topLink.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.flot.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript">
	var oTable = null;
	$(document)
			.ready(
					function() {
						$('.dropdown-toggle').dropdown();
						$(".collapse").collapse();
						oTable = $("#mobilePaymentList")
								.dataTable(
										{
											"oLanguage" : {
												"sUrl" : "js/i18n/table_zh.txt"
											},
											"aoColumns" : [
													{
														"mDataProp" : "id",
														"sWidth" : "15%"
													},
													{
														"mDataProp" : "username",
														"sWidth" : "20%",
														"bUseRendered" : false,
														"fnRender" : function(
																obj) {
															return "<a href='mobilepayment/view?id="
																	+ obj.aData.id
																	+ "'>"
																	+ obj.aData.username
																	+ "</a>";
														}
													},
													{
														"mDataProp" : "phoneNumber",
														"sWidth" : "20%"
													},
													{
														"mDataProp" : "lastUpdateTime",
														"sWidth" : "20%"
													},
													{
														"mDataProp" : "payType",
														"sWidth" : "20%",
														"fnRender" : function(
																obj) {
															return "<div class='btn-group'><a class='btn seton' data-id="+obj.aData.id+" data-username="+obj.aData.username+">开启</a><a class='btn setoff' data-id="+obj.aData.id+" data-username="+obj.aData.username+">关闭</a></div>";
														}
													} ],

											"bPaginate" : true,
											"sPaginationType" : 'full_numbers',
											"aLengthMenu" : [
													[ 5, 10, 15, 20, 30 ],
													[ 5, 10, 15, 20, 30 ] ],
											"bFilter" : false,
											"bSort" : false,
											"bServerSide" : true,
											"sScrollX" : "960px",
											"fnServerData" : function(sSource,
													aoData, fnCallback) {
												var data = {};
												$("#searchForm")
														.find(
																"input[checked], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], select option:selected, textarea")
														.each(
																function() {
																	data[this.name
																			|| this.parentNode.name] = this.value;
																});

												var aoDataMap = toAoDataMap(aoData);
												data.offset = aoDataMap.iDisplayStart;
												data.fetchSize = aoDataMap.iDisplayLength;
												$
														.ajax({
															"dataType" : 'json',
															"type" : "POST",
															"url" : "mobilepayment/list",
															"data" : data,
															"success" : function(
																	data) {
																var aoData = {
																	iDisplayStart : data.offset,
																	iDisplayLength : data.fetchSize,
																	aaData : data.data,
																	iTotalDisplayRecords : data.total,
																	iTotalRecords : data.total
																};
																fnCallback(aoData);
															}
														});
											}
										});

						$('#top-link').topLink({
							min : 400,
							fadeSpeed : 500
						});

						$("#searchForm").submit(function(e) {
							oTable.fnPageChange('first');
							return false;
						});
						
					});

	$("#mobilePaymentList .seton").live(
			"click",
			function(e) {
				var id = $(e.target).attr("data-id");
				var username = $(e.target).attr("data-username");
				if (!confirm("Are you sure to seton the user [" + username
						+ "]?")) {
					return "";
				}
				$.ajax({
					type : 'POST',
					url : "mobilepayment/seton?userId=" + id,
					data : "",
					success : function(returnMessage) {
						if (returnMessage == "true") {
							var ipage = getDateTablePageInfo(oTable
									.fnSettings()).iPage;
							oTable.fnPageChange(ipage);
						} else {
						}
					}
				});


			});

	$("#mobilePaymentList .setoff").live(
			"click",
			function(e) {
				var id = $(e.target).attr("data-id");
				var username = $(e.target).attr("data-username");
				if (!confirm("Are you sure to setoff the user [" + username
						+ "]?")) {
					return "";
				}
				$.ajax({
					type : 'POST',
					url : "mobilepayment/setoff?userId=" + id,
					data : "",
					success : function(returnMessage) {
						if (returnMessage == "true") {
							var ipage = getDateTablePageInfo(oTable
									.fnSettings()).iPage;
							oTable.fnPageChange(ipage);
						} else {
						}
					}
				});
			});
</script>
</head>
<body>
	<div class="page">
		<page:view page="/common/left?menu=mobilepayment" />
		<div id="main" class="main container">
			<page:view page="/common/header?parentTitle=手机支付管理&childTitle=申请开通手机支付功能的用户列表" />
			<div id="menu" class="row-fluid menu">
				<form class="form-search" id="searchForm">
					<input type="text" name="queryParam" id="queryParam" class="input-medium search-query"
						placeholder="请输入用户名或手机号码"> 
						<span class="block">
							<div class="btn-group">
								<input type="submit" class="btn btn-primary" value="搜索">
							</div>
						</span>
				</form>
			</div>
			<div class="row-fluid">
				<div class="widget">
					<div class="header"></div>
					<div class="inner">
						<table id="mobilePaymentList">
							<thead>
								<tr>
									<th>用户ID</th>
									<th>用户名</th>
									<th>电话号码</th>
									<th>申请开通手机支付时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div id="footer" class="row section footer" width="960px">
				<label class="copyright">©舜亚科技 2012</label>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<a href="#top" id="top-link">回到顶部</a>
</body>
</html>